<template>
	<view style="background-color:#f5f5f5">
		<view style="background-color: white;border-bottom: 1px solid white;padding-top: 20rpx;" class="step">
			<up-steps :current="current" activeColor='green'>
				<up-steps-item title="分配中"></up-steps-item>
				<up-steps-item title="接单中"></up-steps-item>
				<up-steps-item title="备货中"></up-steps-item>
				<up-steps-item title="发货中"></up-steps-item>
				<up-steps-item title="回款|签收"></up-steps-item>
				<up-steps-item title="完结"></up-steps-item>
			</up-steps>
		</view>
		<!-- 	<up-line color="#f5f5f5"></up-line> -->
		<u-gap height="5" bgColor="#cccccc"></u-gap>
		<view class="form">
			<view style="background-color: white;padding: 0rpx;">
				<up-tabs @click="tabsClick" :list="titleList" lineWidth="60" :current="currentTab" lineColor="red"
					:activeStyle="{
            color: '#303133',
            fontWeight: 'bold',
            transform: 'scale(1.05)'
        }" :inactiveStyle="{
            color: '#9ca0a6',
            transform: 'scale(1)'
        }" itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;">
				</up-tabs>
			</view>
			<up-line color="#55aa00" style="margin-bottom: 20rpx;"></up-line>
			<view class="viewData" v-show="currentTab == 0">
				<huanDan :data="orderInfo" v-if="type == 3"></huanDan>
				<up-form labelPosition="left" class="apply-form-field" :labelStyle="labelStyle" :borderBottom="false"
					:model="orderInfo" v-else>
					<up-form-item borderBottom="false" label-width="160" label="订单号">
						<u-text :text="orderInfo.orderSum" decoration="underline" type="primary" size="17" style="height: 45rpx;" @click="copyOrder"></u-text>
						<!-- <up-input v-model="orderInfo.orderSum" border="none" readonly></up-input> -->
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="下单日期">
						<up-input v-model="orderInfo.orderDate" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="客户名称">
						<up-input v-model="orderInfo.customerName" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="付款账期">
						<up-input v-model="orderInfo.accountPeriod" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="发货方式">
						<up-input v-model="orderInfo.choiceCar" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="发货日期">
						<up-input v-model="orderInfo.pickDate" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="销售部门">
						<up-input v-model="orderInfo.department" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="销售类型">
						<up-input v-model="orderInfo.sample" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="所在区域">
						<up-input v-model="orderInfo.area" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="销售人员">
						<up-input v-model="orderInfo.salesPerson" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="跟单员">
						<up-input v-model="orderInfo.gendanyuan" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="是否押车">
						<up-input border="none" readonly>
							<template #prefix>
								{{orderInfo.isUnloading == 0 ?'否':'是'}}
							</template>
						</up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="押车天数" v-if="orderInfo.isUnloading == 1">
						<up-input v-model="orderInfo.unloadingDays" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="预计押车费用"
						v-if="orderInfo.isUnloading == 1">
						<up-input v-model="orderInfo.unloadingFare" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="收货人">
						<up-input v-model="orderInfo.customerTake" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="收货人电话">
						<up-input v-model="orderInfo.customerPhone" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="收货人地址">
						<up-input border="none" readonly>
							<template #prefix>
								{{orderInfo.textProvince+'/'+orderInfo.textCity+'/'+orderInfo.textArea}}
							</template>
						</up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="收货人详细地址">
						<up-input v-model="orderInfo.customerAddress" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="客户形式">
						<up-input v-model="orderInfo.customerForm" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="付款方式">
						<up-input v-model="orderInfo.customerPay" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="付款账号">
						<up-input v-model="orderInfo.customerAccount" border="none" readonly></up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="是否开票">
						<up-input border="none" readonly>
							<template #prefix>
								{{orderInfo.isInvoicing == 0 ?'否':'是'}}
							</template>
						</up-input>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="相关图片">
						<u-upload :fileList="fileList1" name="1" multiple :maxCount="10" disabled
							v-if="this.fileList1.length>0"></u-upload>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="相关文件">
						<u-upload :fileList="fileList2" name="1" multiple :maxCount="10" disabled
							v-if="this.fileList2.length>0"></u-upload>
					</up-form-item>
					<up-form-item borderBottom="false" label-width="160" label="备注">
						<div>{{orderInfo.remake}}</div>
					</up-form-item>
					<up-loadmore loadmoreText="看,我是有底线的哟" color="green" lineColor="green" dashed line />
				</up-form>

			</view>
			<view class="viewData" v-show="currentTab == 1">
				<!-- <up-empty height="750"></up-empty> -->
				<view style="padding: 0rpx 5rpx 0rpx 5rpx;">
					<wuLiuEdit v-if="type == 2" :data="id"></wuLiuEdit>
					<carWuLiuEdit v-else-if="type == 6" :data="id"></carWuLiuEdit>
					<wuLiuDetail v-else :data="id" @getOrderNum="getOrderNum"></wuLiuDetail>
				</view>
			</view>
			<view class="viewData" v-show="currentTab == 2">
				<qianShou v-if="type == 5 && sellOrderInfo.length>0" :belongList="sellOrderInfo"></qianShou>
				<huiKuan v-else-if="type == 4 && sellOrderInfo.length>0" :belongList="sellOrderInfo"></huiKuan>
				<sellGaiJia v-else-if="type == 7 && sellOrderInfo.length>0" :belongList="sellOrderInfo"></sellGaiJia>
				<view style="padding: 0rpx 5rpx 0rpx 5rpx;" v-else>
					<swiper :indicator-dots="true" class="swiper1" @change="swiper1Change($event)">
						<swiper-item v-for="(item,index) in sellOrderInfo" :key="index">
							<up-form labelPosition="left" class="apply-form-field" :labelStyle="labelStyle"
								:borderBottom="false" :model="orderInfo">
								<up-form-item borderBottom="false" label-width="160" label="序号">
									<up-input border="none" readonly>
										<template #prefix>
											<div style="color: red;">{{(index+1)+'/共'+sellOrderInfo.length+'单'}}</div>
										</template>
									</up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="跟单员">
									<up-input border="none" readonly>
										<template #prefix>
											<span v-if="!item.gendanyuan || item.gendanyuan == ''">暂无</span>
											<span v-else>{{ (item.gendanyuan.split(","))[item.gendanyuan.split(",").length - 1]
					                      }}</span>
										</template>
									</up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="SKU名称">
									<up-input v-model="item.skuName" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="外包装">
									<up-input v-model="item.packageMethod" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="内包装">
									<up-input v-model="item.innerPackageMethod" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="产品名称">
									<up-input v-model="item.productName" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="品种">
									<up-input border="none" readonly>
										<template #prefix>
											<template v-for="(item1, index) in item.varietySplits" :key="index">
												{{ item1+"、" }}
											</template>
										</template>
									</up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="等级">
									<up-input v-model="item.grade" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="最小规格/kg">
									<up-input v-model="item.minimum" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="内包装数量/箱">
									<up-input v-model="item.weight" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="外包装订单数量">
									<up-input v-model="item.piece" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="单价(最小规格/元)">
									<up-input v-model="item.price" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="订单金额/元">
									<up-input v-model="item.priceTotal" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="采购重量">
									<up-input v-model="item.weightTotal" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="销售单价/公斤/元">
									<up-input v-model="item.desc" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="出库类型">
									<up-input v-model="item.type" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="是否分级">
									<up-input v-model="item.isGraded" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="是否标重">
									<up-input v-model="item.isStandardWeight" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="关联订单">
									<up-input v-model="item.relatedOrderNum" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="新旧货">
									<up-input v-model="item.extent" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="打托方式(箱/托)">
									<up-input v-model="item.palletizingMethod" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="指定园区">
									<div>{{item.companyName}}</div>
									<!-- <up-input v-model="item.companyName" border="none" readonly></up-input> -->
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="备注">
									<div>{{item.notes}}</div>
									<!-- <up-input v-model="item.notes" border="none" readonly type="textarea"></up-input> -->
								</up-form-item>
								<view style="text-align: center;margin-top: 10rpx;">
									<up-tag :text="currentSellPage + '/'+sellOrderInfo.length" plain
										size="mini"></up-tag>
								</view>
								<up-loadmore loadmoreText="可左右滑动查看销售订单" color="red" lineColor="red" line />
							</up-form>
						</swiper-item>
					</swiper>
				</view>

			</view>
			<view class="viewData" v-show="currentTab == 3">
				<saleGaiJia v-if="type == 7 && saleOrderInfo.length>0" :indentList="saleOrderInfo"></saleGaiJia>
				<view style="padding: 0rpx 5rpx 0rpx 5rpx;" v-else>
					<swiper :indicator-dots="true" class="swiper2" @change="swiper2Change($event)"
						v-show="saleOrderInfo.length>0">
						<swiper-item v-for="(item,index) in saleOrderInfo" :key="index">
							<up-form labelPosition="left" class="apply-form-field" :labelStyle="labelStyle"
								:borderBottom="false" :model="orderInfo">
								<up-form-item borderBottom="false" label-width="160" label="序号">
									<up-input border="none" readonly>
										<template #prefix>
											<div style="color: red;">{{(index+1)+'/共'+saleOrderInfo.length+'单'}}</div>
										</template>
									</up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="要求发货时间">
									<u-text :text="this.needFhDate" type="primary"></u-text>
									<!-- <u-tag :text="this.needFhDate" plain  size="mini"  style="text-align: center;"></u-tag> -->
								</up-form-item>								
								<up-form-item borderBottom="false" label-width="160" label="SKU名称">
									<up-input v-model="item.skuName" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="外包装">
									<up-input v-model="item.packageMethod" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="内包装">
									<up-input v-model="item.innerPackageMethod" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="产品名称">
									<up-input v-model="item.productName" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="品种">
									<up-input border="none" readonly>
										<template #prefix>
											<template v-for="(item1, index) in item.varietySplits" :key="index">
												{{ item1+'、' }}
											</template>
										</template>
									</up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="等级">
									<up-input v-model="item.grade" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="园区名称">
									<div>{{item.companyName}}</div>
									<!-- <up-input v-model="item.companyName" border="none" readonly></up-input> -->
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="最小规格/kg">
									<up-input v-model="item.minimum" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="箱规（数量）">
									<up-input v-model="item.weight" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="采购单价 / 元">
									<up-input v-model="item.orderPrice" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="外包装订单数量">
									<up-input v-model="item.piece" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="订单重量">
									<up-input v-model="item.weightTotal" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="采购金额 / 元">
									<up-input v-model="item.buyPriceTotal" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="出库类型">
									<up-input v-model="item.type" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="是否分级">
									<up-input v-model="item.isGraded" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="是否标重">
									<up-input v-model="item.isStandardWeight" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="关联订单">
									<up-input v-model="item.relatedOrderNum" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="新旧货">
									<up-input v-model="item.extent" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="打托方式(箱/托)">
									<up-input v-model="item.palletizingMethod" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="备注">
									<up-input v-model="item.notes" border="none" readonly></up-input>
								</up-form-item>
								<view style="text-align: center;margin-top: 10rpx;">
									<up-tag :text="currentSalePage + '/'+saleOrderInfo.length" plain
										size="mini"></up-tag>
								</view>
								<up-loadmore loadmoreText="可左右滑动查看采购订单" color="red" lineColor="red" line />
							</up-form>
						</swiper-item>
					</swiper>
					<up-empty height="750" v-show="saleOrderInfo.length==0"></up-empty>
				</view>
			</view>
			<view class="viewData" v-show="currentTab == 4">
				<view style="padding: 0rpx 5rpx 0rpx 5rpx;">
					<swiper :indicator-dots="true" indicator-active-color="#7dfa00" class="swiper3"
						@change="swiper3Change($event)" v-show="stockList.length>0">
						<swiper-item v-for="(item,index) in stockList" :key="index">
							<up-form labelPosition="left" class="apply-form-field" :labelStyle="labelStyle"
								:borderBottom="false" :model="orderInfo">
								<up-form-item borderBottom="false" label-width="160" label="序号">
									<up-input border="none" readonly>
										<template #prefix>
											<div style="color: red;">{{(index+1)+'/共'+stockList.length+'单'}}</div>
										</template>
									</up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="SKU名称">
									<up-input v-model="item.skuName" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="产品名称">
									<up-input v-model="item.productName" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="品种">
									<up-input v-model="item.varietyName" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="等级">
									<up-input v-model="item.grade" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="是否分级">
									<up-input v-model="item.type" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="包装方式">
									<up-input v-model="item.packageMethod" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="新旧货">
									<up-input v-model="item.extent" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="最小规格/kg">
									<up-input v-model="item.minimum" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="箱规(件数)">
									<up-input v-model="item.weight" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="应备件数">
									<up-input v-model="item.piece" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="应发重量(kg)">
									<up-input v-model="item.weightTotal" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="已入库量(kg)">
									<up-input v-model="item.weightTotalRu" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="已发件数">
									<up-input v-model="item.piece_fh_sum" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="已发重量(kg)">
									<up-input v-model="item.weight_fh_sum" border="none" readonly></up-input>
								</up-form-item>
								<view style="text-align: center;margin-top: 10rpx;">
									<up-tag :text="currentStockPage + '/'+stockList.length" plain size="mini"></up-tag>
								</view>
								<up-loadmore loadmoreText="可左右滑动查看备货单" color="red" lineColor="red" line />
							</up-form>
						</swiper-item>
					</swiper>
					<up-empty height="750" v-show="stockList.length==0"></up-empty>
				</view>

			</view>
			<view class="viewData" v-show="currentTab == 5">
				<view style="padding: 0rpx 5rpx 0rpx 5rpx;">
					<swiper :indicator-dots="true" indicator-active-color="#00aa00" class="swiper4"
						@change="swiper4Change($event)" v-show="faHuoList.length>0">
						<swiper-item v-for="(item,index) in faHuoList" :key="index">
							<up-form labelPosition="left" class="apply-form-field" :labelStyle="labelStyle"
								:borderBottom="false" :model="orderInfo">
								<up-form-item borderBottom="false" label-width="160" label="序号">
									<up-input border="none" readonly>
										<template #prefix>
											<div style="color: red;">{{(index+1)+'/共'+faHuoList.length+'条记录'}}</div>
										</template>
									</up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="实际发货日期">
									<up-input v-model="item.fh_data" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="收货人">
									<up-input v-model="item.fh_person" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="收货地址">
									<div>{{item.fh_address}}</div>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="收货人电话">
									<up-input v-model="item.fh_phone" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="承运人">
									<up-input v-model="item.driver_name" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="承运人电话">
									<up-input v-model="item.phone" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="身份证号码">
									<up-input v-model="item.id_card" border="none" readonly></up-input>
								</up-form-item>
								<up-form-item borderBottom="false" label-width="160" label="车牌号">
									<up-input v-model="item.numberplate" border="none" readonly></up-input>
								</up-form-item>
								<view class="workbench-title">发货详情</view>
								<view>
									<zb-table :show-header="true" :columns="column" :stripe="true" :fit="false"
										:border="true" :data="item.detail"></zb-table>
								</view>

								<view style="text-align: center;margin-top: 90rpx;">
									<up-tag :text="currentFaHuoPage + '/'+faHuoList.length" plain size="mini"></up-tag>
								</view>
								<up-loadmore loadmoreText="可左右滑动查看发货记录" color="red" lineColor="red" line />
							</up-form>

						</swiper-item>
					</swiper>
					<up-empty height="750" v-show="faHuoList.length==0"></up-empty>
				</view>
			</view>

			<!-- 		<lzcPicker ref="lzcPicker" @change="driverConfirm" :pickerList="carryList"
			pickerTittle='点击车牌即可,若无车牌,请手动填写' /> -->
		</view>
		<!-- 		<u-datetime-picker
			:show="driverDateShow"
			v-model="arrivalTime"
			mode="datetime"
			closeOnClickOverlay
			@confirm="arrivalTimeConfirm"
			@cancel="driverDateShow =false"
			@close="driverDateShow =false"
		></u-datetime-picker>	 -->
		<u-action-sheet :actions="actionList" :closeOnClickOverlay="true" :closeOnClickAction="true" 
		  title="更多功能"  :show="actionShow" round="10" cancelText="取消" @close="actionShow = false" @select="selectAction"></u-action-sheet>
		  
		<log v-if="logShow" :popupShow="logShow" @closeLog="closeLog" :id="id" :status="status"></log>  
	</view>
</template>

<script>
	import orderApi from '@/apis/gyl/order.js';
	import baseApi from '@/apis/gyl/base.js';
	import wuliuApi from '@/apis/gyl/wuliu.js';
	import lzcPicker from '@/components/driver-picker/lzc-picker.vue';
	import wuLiuEdit from '@/components/order/sellWuLiuEdit.vue';
	import wuLiuDetail from '@/components/order/wuliuDetail.vue';
	import carWuLiuEdit from '@/components/order/carWuLiuEdit.vue';
	import huanDan from '@/components/order/huanDan.vue';
	import qianShou from '@/components/order/qianShou.vue';
	import huiKuan from '@/components/order/huiKuan.vue';
	import sellGaiJia from '@/components/order/sellGaiJia.vue';
	import saleGaiJia from '@/components/order/saleGaiJia.vue';
	import log from '@/components/order/log.vue';
	import {copyOrderInfo} from '@/utils/copy.js'
	export default {
		components: {
			lzcPicker,
			wuLiuEdit,
			wuLiuDetail,
			carWuLiuEdit,
			huanDan,
			qianShou,
			huiKuan,
			sellGaiJia,
			saleGaiJia,
			log
		},
		onNavigationBarButtonTap(e) {
			console.log("sasa")
			if (e.index === 0) {
				this.actionShow = true
			}
		},
		data() {
			return {
				logShow: false,
				actionShow:false,
				actionList: [
					{
						name:'查看订单日志',
						index:0
					}
				],			
				needFhDate:'',
				// wuLiu: {
				// 	carCard: null,
				// 	carryDriver: null,
				// 	phone: null,
				// 	arrivalTime: null,
				// },
				// arrivalTime:Number(new Date()),
				// carryList:[],
				type: 1, //1详情 2物流
				sourceCarryList: [],
				current: 0,
				driverDateShow: false,
				labelStyle: {
					color: '#aaa',
					fontSize: '30rpx'
				},
				column: [{
						name: 'skuName',
						label: 'SKU名称',
						width: 140
					},
					{
						name: 'm_name',
						label: '产品名称',
					},
					{
						name: 'm_desc',
						label: '等级',
					},
					{
						name: 'packing',
						label: '包装方式',
					},
					{
						name: 'piece',
						label: '实际发货数量',
						width: 120
					},
					{
						name: 'num',
						label: '实际发货重量',
						width: 120
					}
				],
				stockList: [],
				faHuoList: [],
				currentSellPage: 1,
				currentSalePage: 1,
				currentStockPage: 1,
				currentFaHuoPage: 1,
				currentTab: 0,
				list: [{
						key: 'plus',
						name: 'plus',
						color: '#fff',
						backgroundColor: 'red'
					},
					{
						key: 'order',
						name: 'order',
						color: '#fff',
						backgroundColor: 'green'
					}
				],
				orderInfo: {}, //客户信息
				sellOrderInfo: [], //销售订单
				saleOrderInfo: [], //采购订单
				id: null, //订单id
				status: null,
				fileList1: [],
				fileList2: [],
				sourceTitleList: [{
						name: '客户信息',
						badge: {
							value: 0
						},
					},
					{
						name: "物流信息",
						badge: {
							value: 0
						},
					},
					{
						name: '销售订单',
						badge: {
							value: 0
						},
					},
					{
						name: '采购订单',
						badge: {
							value: 0
						},
					},
					{
						name: '备货单',
						badge: {
							value: 0
						},
					},
					{
						name: '发货记录',
						badge: {
							value: 0
						},
					},
				],
				titleList: [],
				title1List: ['客户信息', '物流', '销售订单', '采购订单', '备货单', '发货记录'],
				// driverRules: {
				// 	carCard: [{
				// 		required: true,
				// 		message: '请填写/选择车牌号',
				// 		trigger: ['blur', 'change']
				// 	}],
				// 	carryDriver: [{
				// 		required: true,
				// 		message: '请填写承运司机',
				// 		trigger: ['blur', 'change']
				// 	}],
				// 	phone: [{
				// 		required: true,
				// 		message: '请填写手机号',
				// 		trigger: ['blur', 'change']
				// 	}],
				// 	arrivalTime: [{
				// 		required: true,
				// 		message: '请选择预计到园区时间',
				// 		trigger: ['blur', 'change']
				// 	}],
				// }
			}
		},
		methods: {
			copyOrder(){
				if(this.saleOrderInfo && this.saleOrderInfo.length>0){
					copyOrderInfo(this.orderInfo,this.saleOrderInfo,1)
				}else{
					copyOrderInfo(this.orderInfo,this.sellOrderInfo,0)
				}
			},
			getOrderNum(callback){
				callback(this.orderInfo.orderSum)
			},
			closeLog(){
				this.logShow = false;
			},
			selectAction(e){
				if(e.index == 0){//查看日志
					this.logShow = true
				}
			},
			swiper1Change(item) {
				this.currentSellPage = item.detail.current + 1;
			},
			swiper2Change(item) {
				this.currentSalePage = item.detail.current + 1;
			},
			swiper3Change(item) {
				this.currentStockPage = item.detail.current + 1;
			},
			swiper4Change(item) {
				this.currentFaHuoPage = item.detail.current + 1;
			},
			tabsClick(item) {
				this.currentTab = item.index;
				this.currentSellPage = 1;
				this.currentSalePage = 1;
				this.currentStockPage = 1;
				this.currentFaHuoPage = 1;
			},
			// driverConfirm(index){
			// 	const data = this.sourceCarryList[index];
			// 	this.wuLiu.carCard = data.carCard;
			// 	this.wuLiu.carryDriver = data.carryDriver;
			// 	this.wuLiu.phone = data.phone;
			// },
			// driverShowClick(){
			// 	this.$refs.lzcPicker.handleShow();
			// },

			/**
			 * 预计到园区时间
			 */
			// arrivalTimeConfirm(){
			// 	const timeFormat = uni.$u.timeFormat;
			// 	this.wuLiu.arrivalTime = timeFormat( this.arrivalTime, 'yyyy-mm-dd hh:MM')
			// 	this.driverDateShow = false;
			// },

			/**
			 * app 调用
			 */
			// driverDateClick(){
			// 	this.driverDateShow = true;
			// },

			/**
			 * 物流保存
			 */
			// async wuLiuSave(){
			// 	await this.$refs.wuLiuRef.validate().then(res => {

			// 	}).catch(errors => {
			// 		uni.$u.toast(errors[0].message)
			// 	})
			// 	const res = await wuliuApi.saveLogistic({data:this.wuLiu,saleId:this.id});
			// 	if(res.success){
			// 		uni.showToast({
			// 			icon: 'none',
			// 			duration: 3000,
			// 			title: '物流分配成功'
			// 		});
			// 		uni.navigateBack()
			// 	}else{
			// 		uni.showToast({
			// 			icon: 'none',
			// 			duration: 3000,
			// 			title: '物流分配失败'
			// 		});					
			// 	}
			// },
			async getStockList(orderNum, dbName) {
				const res = await orderApi.getStockList(this.id);
				if (res.success) {
					this.stockList = res.data;
					if (this.current >= 3) {
						this.getFHJL(orderNum, dbName, this.stockList);
					}
					this.titleList[4].badge.value = this.stockList.length;
					var formData = {
						'order_no': orderNum,
						'new_db_name': dbName
					}
					const params = new URLSearchParams();
					for (var i = 0; i < this.stockList.length; i++) {
						for (let key in this.stockList[i]) {
							if (!formData.hasOwnProperty(key)) {
								if (this.stockList[i][key] != null) {
									formData['cp_info' + '[' + i + '][' + key + ']'] = this.stockList[i][key];
								} else {
									formData['cp_info' + '[' + i + '][' + key + ']'] = '';
								}
							}
						}
					}
					const phpRes = await baseApi.getStockList(formData);
					if (phpRes.status > 0) {
						phpRes.data.map((item) => {
							this.stockList.map((ab) => {
								//如果是拆分的数据，就将返回值和子单进行比对，并将数值累加
								if (ab.stockSplitList) {
									ab.stockSplitList.map((cc) => {
										if (item.gyl_split_id == cc.id && item.stockId) {
											cc.rkSum = item.sum;
											cc.beiSum = item.piece_sum;
											cc.fhjs = item.piece_fh_sum;
											cc.fhNum = item.weight_fh_sum;
										}
									});
								} else {
									if (
										item.m_name == ab.productName &&
										item.m_desc == ab.grade &&
										item.stockId == ab.id
									) {
										ab.weightTotalRu = item.sum;
										ab.piece_sum = item.piece_sum;
										ab.piece_fh_sum = item.piece_fh_sum;
										ab.weight_fh_sum = item.weight_fh_sum;
									}
								}
							});
						});
						phpRes.total.map((item) => {
							this.stockList.map((ab) => {
								if (item.stockId == ab.id) {
									ab.weightTotalRu = item.sum;
									ab.piece_sum = item.piece_sum;
									ab.piece_fh_sum = item.piece_fh_sum;
									ab.weight_fh_sum = item.weight_fh_sum;
								}
							});
						});
					}
				}
			},

			async getDetail() {
				const res = await orderApi.getDetail({
					id: this.id,
					status: this.status
				})
				if (res.success) {
					this.orderInfo = res.data.sellDetail;
					this.sellOrderInfo = this.orderInfo.belongList;
					if (this.orderInfo.orderImage != null && this.orderInfo.orderImage != '') {
						var img = this.orderInfo.orderImage.split(',')
						img.forEach((item) => {
							const map = {
								url: item
							}
							this.fileList1.push(map)
						})
					}
					if (this.orderInfo.orderText != null && this.orderInfo.orderText != '') {
						var signImg = this.orderInfo.orderText.split(',')
						img.forEach((item) => {
							const map = {
								url: item
							}
							this.fileList2.push(map)
						})
					}
					this.titleList[2].badge.value = this.sellOrderInfo.length;
					//采购订单
					if (res.data.saleDetail) {
						if (this.orderInfo.status == 6 || this.orderInfo.status == 7 || this.orderInfo.status == 8) {
							this.current = 4;
							// } else if (this.orderInfo.status == 7 || this.orderInfo.status == 8) {
							// 	this.current = 5;
						} else if (this.orderInfo.status >= 9) {
							this.current = 5;
						} else {
							this.current = this.orderInfo.status - 1;
						}
						if (this.current == 1) {
							this.titleList = this.sourceTitleList.slice(0, 4);
						} else if (this.current == 2) {
							this.titleList = this.sourceTitleList.slice(0, 5);
						} else if (this.current >= 3) {
							this.titleList = this.sourceTitleList.slice(0, 6);
						}
						this.needFhDate = res.data.saleDetail.needFhDate;
						this.saleOrderInfo = res.data.saleDetail.indentList;
						this.titleList[3].badge.value = this.saleOrderInfo.length;
						if (this.current >= 2) {
							this.getStockList(res.data.saleDetail.orderTimeStamp, res.data.saleDetail.dbName);
						}
					}
				}
			},

			/**
			 * 获取发货记录
			 */
			async getFHJL(orderNum, dbName, stockList) {
				var query = {
					order_num: orderNum,
					new_db_name: dbName,
				}
				const res = await baseApi.getFHList(query);
				if (res.status > 0) {
					let map = new Map();
					stockList.forEach((item) => {
						map.set(item.id, item.skuName);
					})
					this.faHuoList = res.data;
					this.faHuoList.forEach((item) => {
						item.detail.forEach((item1) => {
							this.$set(item1, "skuName", map.get(item1.gyl_detail_id))
						})
					})
					this.titleList[5].badge.value = this.faHuoList.length;
				}
			},
			/**
			 * 获取物流数据
			 */
			// async getWUliu() {
			// 	const res = await wuliuApi.getLogisic(this.id);
			// 	if (res.success) {
			// 		if (res.data) {
			// 			this.wuLiu = res.data;
			// 		} else {
			// 			this.wuLiu = {};
			// 		}

			// 	}
			// },

			/**
			 * 获取所有的司机列表
			 */
			// async getCarryList(){
			// 	const res = await wuliuApi.selectAll();
			// 	if (res.success) {
			// 		this.sourceCarryList = res.data;
			// 	   const carCardList = res.data.map((item, index) => ({
			// 	   	carCard: item.carCard,
			// 	   	index: index
			// 	   }));
			// 	   this.carryList = carCardList;
			// 	}				
			// }
		},
		onReady() {
			if (this.type == 2 || this.type == 6) {
				uni.setNavigationBarTitle({
					title: '物流分配'
				});
			} else if (this.type == 3) {
				uni.setNavigationBarTitle({
					title: '订单换单'
				});
			} else if (this.type == 4) {
				uni.setNavigationBarTitle({
					title: '订单回款'
				});
			} else if (this.type == 5) {
				uni.setNavigationBarTitle({
					title: '订单签收'
				});
			}else if (this.type == 7) {
				uni.setNavigationBarTitle({
					title: '订单改价'
				});
			}
		},
		onLoad(option) {
			this.id = option.id;
			this.status = option.status;
			this.titleList = this.sourceTitleList.slice(0, 3);
			this.type = option.type;
			if (option.type == 2 || option.type == 6) {
				this.currentTab = 1;
			} else if (option.type == 5 || option.type == 4 || option.type == 7) {
				this.currentTab = 2;
			}

			this.getDetail();
			// this.getWUliu();
			// this.getCarryList();
		}
	}
</script>

<style scoped>
	/* 	.step {
		border-bottom: 1px solid #d7d9da;
		box-shadow: 5px 5px 12px rgba(0, 0, 0, 0.3);
	} */

	.tabs {
		/* 		border-top: 2px solid #dbdbdb; */
		/* 		box-shadow: 5px 5px 12px rgba(0, 0, 0, 0.2);
		border-radius: 5px;	 */
	}

	.u-form {
		border: 1px solid #bdbdbd;
		/* 	box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3); */
		border-radius: 15px;
	}

	.slot-icon {
		width: 21px;
		height: 21px;
		background-color: #f9ae3d;
		border-radius: 100px;
		font-size: 12px;
		color: #fff;
		line-height: 21px;
		text-align: center;
	}

	.form {
		/* 	margin-top: 10rpx; */
		background-color: #fff;
		border-left: 1px solid #bcbcbd;
		/* border-top: 2px solid #f0f0f1; */
		border-right: 1px solid #bcbcbd;
		border-bottom: 1px solid #bcbcbd;
		box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.3);
		/* 	border-radius: 15px; */
	}

	::v-deep .u-form-item__body {
		padding: 0rpx 0rpx !important;
	}

	::v-deep .u-form-item {
		padding: 0px 40rpx !important;
	}

	.viewData {
		background-color: white;
		padding: 0rpx 5rpx 200rpx 5rpx;
	}

	/* 	.uni-input-input{
		color: red;
	} */
	.swiper1 {
		height: 1350rpx;
	}

	.swiper2 {
		height: 1250rpx;
	}

	.swiper3 {
		height: 1250rpx;
	}

	.swiper4 {
		height: 1100rpx;
	}

	.u-empty {
		height: 1200rpx;
	}

	::v-deep #app {
		background-color: #f5f5f5 !important;
	}

	.workbench-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #333333;
		padding: 10px 30rpx;
		margin-bottom: 10px;
	}

	.item-th {
		background-color: #d7d7d8;
	}

	.apply-form-field {
		background: #ffffff;

		.input-placeholder {
			text-align: left !important;
			font-size: 28rpx;
		}

		.uni-input-input {
			text-align: left !important;
		}

		.form-field-select {
			.u-iconfont {
				font-size: 0 !important;
			}
		}

		.add-user {
			color: #bfbfbf;
			font-size: 30px;
		}

		.apply-name {
			color: #333333;
			line-height: 20px;

			span {
				color: #999999;
				display: block;

			}
		}

		.apply-link {
			.u-link {
				color: #5ab149 !important;
				padding: 0 5px;
			}
		}

		.u-close--top-right {
			top: 5px !important;
		}

		.popup-title {
			color: #333333;
			padding: 5px 10px;
			font-size: 30rpx;
		}

		.u-cell {
			padding: 8px 12px !important;
		}
	}
	::v-deep .u-action-sheet__item-wrap{
		border-top: 1px solid #c7c7c7;
	}
</style>